package com.shen.accountbook.module.home.booknote;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;

import com.shen.accountbook.bean.temp.NoteBeanTemp;
import com.shen.accountbook.bean.temp.SecondSortBean;
import com.shen.accountbook.bean.temp.ThirdSortBean;
import com.shen.accountbook.bean.temp.biz.NoteBeanTempBiz;
import com.shen.accountbook.bean.temp.biz.ThirdSortBeanBiz;
import com.shen.accountbook.module.base.BasePresenter;
import com.shen.accountbook.module.base.EmptyModelImpl;
import com.shen.accountbook.module.base.EmptyView;

import java.util.List;

/**
 * author:  shen
 * date:    2018/6/27
 */
public class BookNotePresenterImpl extends BasePresenter<BookNoteView, BookNoteModelImpl> {

    public BookNotePresenterImpl(Context context, BookNoteView mvpView) {
        super(context, mvpView);
    }

    @Override
    protected BookNoteModelImpl createModel() {
        return new BookNoteModelImpl();
    }


    protected GridLayoutManager getLayoutManager(){
        GridLayoutManager layoutManager = new GridLayoutManager(mContext, 5);
        return layoutManager;
    }


    /**
     * 数据库中获取"三级分类" -- 根据第一分类获取第三分类
     * @return
     */
    protected List<ThirdSortBean> getThirdSortList(long firstId) {
        ThirdSortBeanBiz biz = new ThirdSortBeanBiz();
        return biz.getBeanByFirstId(firstId);
    }

    /**
     * 根据"第一分类获"和"使用频率"取第三分类 -- 使用频率要大于0
     * @return
     */
    protected List<ThirdSortBean> getThirdSortBeanByFirstIdFrequency(long firstId) {
        ThirdSortBeanBiz biz = new ThirdSortBeanBiz();
        return biz.getBeanByFirstIdFrequency(firstId);
    }


    /**
     * 数据库中获取"三级分类" -- 根据第一分类获取第三分类
     * @return
     */
    protected List<List<ThirdSortBean>> getThirdSortBeanByFirstIdSecondIdList(long firstId) {
        ThirdSortBeanBiz biz = new ThirdSortBeanBiz();
        return biz.getBeanByFirstIdSecondId(firstId);
    }



    /**
     * 根据第一分类获取
     * @return
     */
    protected List<NoteBeanTemp> getNoteBeanByFirstId(long firstId) {
        NoteBeanTempBiz biz = new NoteBeanTempBiz();
        return biz.getBeanByFirstId(firstId);
    }

    /**
     * 插入记录
     * @return
     */
    protected boolean insertNoteBean(NoteBeanTemp bean) {
        NoteBeanTempBiz biz = new NoteBeanTempBiz();
        return biz.insertAuto(bean);
    }

    /**
     * 跟新
     * @return
     */
    protected void update(NoteBeanTemp bean) {
        NoteBeanTempBiz biz = new NoteBeanTempBiz();
        biz.update(bean);
    }

    /**
     * 更新使用频率第三分类
     */
    protected void updateFrequency(long thirdId) {
        ThirdSortBeanBiz biz = new ThirdSortBeanBiz();
        biz.updateFrequency(thirdId);
    }
}
